﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Loki.Model
{
	/// <summary>
	/// Unique index configuration for entity container
	/// </summary>
	/// <typeparam name="TEntityClass">Entity class type</typeparam>
	/// <typeparam name="TEntityKey">Entity key type</typeparam>
	public class UniqueKeyConfiguration<TEntityClass, TEntityKey>
	{
		/// <summary>
		/// Gets or sets the indexer.
		/// </summary>
		/// <value>
		/// The indexer.
		/// </value>
		public Expression<Func<TEntityClass, TEntityKey>> Indexer
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the loader.
		/// </summary>
		/// <value>The loader.</value>
		public Func<TEntityKey, TEntityClass> Loader
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the "not found" error code.
		/// </summary>
		/// <value>The not found error code.</value>
		public string NotFoundErrorCode
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the default value when an item is not found
		/// </summary>
		public Func<TEntityKey, TEntityClass> Default
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the index comparer
		/// </summary>
		public IEqualityComparer<TEntityKey> Comparer
		{
			get;
			set;
		}
	}
}
